{% extends "piggy/base_generic.html" %}

{% block title %}
    <title>{{ plan.name }} - Plan's details</title>
{% endblock %}

{% block content %}
    <h1> {{ plan.name }} </h1>
    <p>
        <strong>Professor:</strong>
        <a href="{% url 'piggy:teacher_detail' plan.teacher.id %}">{{ plan.teacher }}</a>
    </p>

    <p>
        <strong>Status:</strong>
        {% if plan.is_expired %}
            Expired
            {% if flag %}
                <a href="{% url 'piggy:start_plan' plan.id %}">Start plan</a>
            {% endif %}
        {% else %}
            Running
            {% if flag %}
                <a href="{% url 'piggy:stop_plan' plan.id %}">Stop plan</a>
            {% endif %}
        {% endif %}
    </p>
    <p>Projects in this plan:</p>
    <ul>
        {% for project in plan.project_set.all %}
            <li><a href="{% url 'piggy:project_detail' project.id %}">{{ project.name }}</a></li>
        {% endfor %}
    </ul>
    {% if flag %}
        <p><a href="{% url 'piggy:add_project' plan.id %}">Add a project</a></p>
    {% endif %}
    <p>Teams in this plan:</p>
    <ul>
        {% for team in teams %}
            <li><a href="{% url 'piggy:team_detail' team.id %}">{{ team.name }}</a></li>
        {% endfor %}
    </ul>

    <p><a href="{% url 'piggy:create_team' plan.id %}">Create a Team</a></p>
    
    {% if flag %}
        <p><a href="{% url 'piggy:edit_plan' plan.id %}">Edit Plan</a></p>
    {% endif %}
    
{% endblock %}
